﻿using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Activation;
using OMIP.HMS.Access;
using OMIP.HMS.Model;

namespace OMIP.HMS.WCFService
{
        // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码、svc 和配置文件中的类名“Service1”。
        // 注意: 为了启动 WCF 测试客户端以测试此服务，请在解决方案资源管理器中选择 Service1.svc 或 Service1.svc.cs，然后开始调试。
        [ServiceContract(Namespace = "")]
        [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
        public class HMSService
        {
                #region 属性

                private readonly DBStorage _db = DBStorage.Instance;

                #endregion

                #region 方法

                #region 病人

                [OperationContract]
                public void InsertPatientModel(PatientModel model)
                {
                        _db.Insert(model);
                }

                [OperationContract]
                public List<PatientModel> SelectPatientModels()
                {
                        return _db.Select<PatientModel>();
                }

                [OperationContract]
                public PatientModel SelectPatientModel(string id)
                {
                        return _db.Select<PatientModel>(id);
                }

                [OperationContract]
                public void UpdatePatientModel(PatientModel model)
                {
                        _db.Update(model);
                }

                [OperationContract]
                public void DeletePatientModel(PatientModel model)
                {
                        _db.Delete(model);
                }

                [OperationContract]
                public void DeletePatientModels()
                {
                        _db.Select<PatientModel>().ForEach(i => _db.Delete(i));
                }

                #endregion

                #region 人员

                [OperationContract]
                public void InsertEmployeeModel(EmployeeModel model)
                {
                        _db.Insert(model);
                }

                [OperationContract]
                public List<EmployeeModel> SelectEmployeeModels()
                {
                        return _db.Select<EmployeeModel>();
                }

                [OperationContract]
                public EmployeeModel SelectEmployeeModel(string id)
                {
                        return _db.Select<EmployeeModel>(id);
                }

                [OperationContract]
                public void UpdateEmployeeModel(EmployeeModel model)
                {
                        _db.Update(model);
                }

                [OperationContract]
                public void DeleteEmployeeModel(EmployeeModel model)
                {
                        _db.Delete(model);
                }

                [OperationContract]
                public void DeleteEmployeeModels()
                {
                        _db.Select<EmployeeModel>().ForEach(i => _db.Delete(i));
                }

                #endregion

                #endregion
        }
}
